package com.wstx.mediaserver.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class Res<T> {
    public static final Integer sucCode = 0;
    public static final Integer failCode = -1;
    public static final String sucMsg = "请求成功";
    public static final String failMsg = "请求失败";

    protected Integer code;

    protected String msg;

    protected T data;

    public static Res<String> suc(){
        return new Res<>(sucCode,sucMsg,null);
    }

    public Res<T> suc(T data){
        return new Res<>(sucCode,sucMsg,data);
    }

    public static Res<String> fail(String failMsg){
        return new Res<>(failCode,failMsg,null);
    }

    public boolean success(Res<T> res){
        return res.code.equals(sucCode);
    }
}
